In the previous step, you set up your application and added controls. In this step, you'll add the necessary resource files and add some of the code that controls printing. In this step, you'll add a resource file that was installed with your ComponentOne Studio UWP Edition Samples. You can find the samples in the Documents folder of your system.
C# |
Copy Code
|
---|---|
using Windows.UI.Xaml.Printing; using C1.Xaml.RichTextBox; using Windows.UI.ViewManagement; using Windows.Graphics.Printing; using System.Reflection; using Windows.UI.Popups; |
C# |
Copy Code
|
---|---|
public sealed partial class MainPage : Page { /// <summary> /// PrintDocument is used to prepare the pages for printing. /// Prepare the pages to print in the handlers for the Paginate, GetPreviewPage, and AddPages events. /// </summary> protected PrintDocument printDocument = null; /// <summary> /// Marker interface for document source /// </summary> protected IPrintDocumentSource printDocumentSource = null; /// <summary> /// A list of UIElements used to store the rtb pages. /// </summary> internal List<FrameworkElement> pages = null; /// <summary> /// Used for printing the document of C1RichTextBox. /// </summary> C1RichTextViewManager viewManager; |
C# |
Copy Code
|
---|---|
public MainPage() { this.InitializeComponent(); Assembly asm = typeof(MainPage).GetTypeInfo().Assembly; Stream stream = asm.GetManifestResourceStream("YourApplicationName.Resources.dickens.htm"); var html = new StreamReader(stream).ReadToEnd(); rtb.Html = html; pages = new List<FrameworkElement>(); this.Loaded += Printing_Loaded; this.Unloaded += Printing_Unloaded; } |
In this step, you added a Resources file, and the appropriate existing dickens.htm file. You also added code to the MainPage.xaml.cs file. In the next step, you'll add the rest of the code to handle the Button_Click event for the general Button control, and the Printing events that you added in the MainPage() constructor.